//################################
// 版权所有：鸽子游戏俱乐部
// 系统名称：鸽子游戏俱乐部-移动版
// 文件名称：configureStore.js
// 创建时间：2016年06月28日
// 创建人员：Panda
// 功能说明：redux store configure
//################################

'use strict';

import { applyMiddleware, createStore } from 'redux';
import thunk from 'redux-thunk';
import {createLogger} from 'redux-logger';

import reducers from '../reducers';
import promise from './promise';
import pandaLogger from '../middleware/pandaLogger';

var isDebuggingInChrome = __DEV__ && !!window.navigator.userAgent;

var logger = createLogger({
  predicate: (getState, action) => isDebuggingInChrome,
  collapsed: true,
  duration: true,
});

var store = applyMiddleware(thunk, promise, logger, pandaLogger)(createStore)(reducers);

function configureStore() {
  if (isDebuggingInChrome) {
    window.store = store;
  }

  return store;
}

module.exports = configureStore;